package com.balabala.gym_goods.controller.app;

import com.balabala.gym_goods.pojo.dto.FindCoachByTimeDto;
import com.balabala.gym_goods.pojo.entity.Course;
import com.balabala.gym_goods.pojo.entity.Evaluation;
import com.balabala.gym_goods.pojo.vo.BookCourseAppVo;
import com.balabala.gym_goods.service.CourseService;
import com.balabala.gym_goods.service.EvaluationService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Author:zl
 * Date:2023/5/6 20:19
 */
@Slf4j
@RestController
@CrossOrigin
@Api(tags = "小程序团课接口")
@RequestMapping("/app/course")
public class CourseAPPController {
    @Autowired
    private CourseService courseService;
    @Autowired
    private EvaluationService evaluationService;

    /*@ApiOperation(value = "当天所有团课")
    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public Result findAll() {
        List<BookCourseAppVo> list = courseService.findByTime();
        System.out.println(list);
        return Result.ok(list);
    }*/

    @ApiOperation(value = "根据时间场馆查询团课")
    @PostMapping(value = "/findAllByTime")
    public Result findAllByTime ( @RequestBody FindCoachByTimeDto findCoachByTimeDto) {
        List<BookCourseAppVo> listByDateVenues = courseService.findByDate(findCoachByTimeDto);
        return Result.ok(listByDateVenues);
    }

    @GetMapping(value = "/findEvaluationBySpuId")
    @ApiOperation(value = "根据商品团课id查询评价")
    public Result findEvaluationBySpuId(@RequestParam Long courseId) {

        List<Evaluation> evaluationBySpuId = evaluationService.findEvaluationByCourseId(courseId);

        return Result.ok(evaluationBySpuId);
    }
}
